package cloud.xiao.controller;

import cloud.xiao.myHandler.GetDHandler;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FlowLimitController {

    @GetMapping("getA")
    public String getA() {
        return "A";
    }

    @GetMapping("getB")
    public String getB() {
        return "B";
    }

    @GetMapping("getc")
    @SentinelResource(value = "getc", blockHandler = "blockHandlerc")
    public String getc(){
        return "getc";
    }

    public String blockHandlerc(BlockException exception) {
        //打印执行的方法名
        System.out.println(exception.getClass().getCanonicalName());
        return "exception blockc";
    }

    @GetMapping("/getD")
    @SentinelResource(value = "getD",
            blockHandlerClass = GetDHandler.class,//去GetDHandler类
            blockHandler = "blockHandlerD")//寻找blockHandlerD方法
    public String getD() {
        return "getD";
    }


}
